From: David Polakovic Date: Mon, 9 Mar 2026 13:18:27 +0000 (+0100) Subject: perf: Removed redundant print_request sub. X-Git-Url: https://git.dpolakovic.space/%22%22.esc_url%28%24base_url%29.%22//%22%24link/%22/%22%22.esc_url%28%24base_url%29.%22//%22%24link/%22?a=commitdiff_plain;ds=inline;p=htcpcp-requestor perf: Removed redundant print_request sub. --- diff --git a/get-coffee-from b/get-coffee-from index 014e3ad..5f31407 100644 --- a/get-coffee-from +++ b/get-coffee-from @@ -26,12 +26,6 @@ sub request_code { return $res->code; } -sub teapot { - print "\nThis server is a teapot.\n"; - print "As per RFC 2324 section 2.3.2: This server is a teapot and refuses to brew coffee.\n"; - print "It may brew tea instead, but coffee is beyond its capabilities.\n"; -} - # curl -X behaviour: sends request with specified method, returns body sub request_body { my ($method, $url) = @_; @@ -43,6 +37,12 @@ sub request_body { return $res->content; } +sub teapot { + print "\nThis server is a teapot.\n"; + print "As per RFC 2324 section 2.3.2: This server is a teapot and refuses to brew coffee.\n"; + print "It may brew tea instead, but coffee is beyond its capabilities.\n"; +} + # find webmaster email in page body sub find_webmaster_email { my ($url) = @_; @@ -76,18 +76,6 @@ sub no_coffee { } } -sub print_response { - my ($method, $url) = @_; - - my $ua = LWP::UserAgent->new(max_redirect => 0, timeout => 10); - my $req = HTTP::Request->new(uc($method) => $url); - my $res = $ua->request($req); - - # print "Status : " . $res->status_line . "\n"; - # print "Headers:\n" . $res->headers->as_string . "\n"; - print $res->content . "\n" if $res->content; -} - ## meat # get the domain @@ -148,10 +136,10 @@ sub good_manners { # decision tree if ($http_brew == 200) { - print_response('BREW', $http_domain); + print request_body('BREW', $http_domain);print "\n"; good_manners('http'); } elsif ($https_brew == 200) { - print_response('BREW', $https_domain); + print request_body('BREW', $https_domain);print "\n"; good_manners('https'); } elsif ($http_brew == 418 || $https_brew == 418) { teapot();